# -*- coding: utf-8 -*-

from django.db import models
from django.contrib.auth.models import User

POSSIBLE_STATUS = (  ("NEW", u"Novo"),
                     ("ANALISYS", u"Análise"),
                     ("CLARIFY", u"Esclareça"),
                     ("RE-SENT", u"Re-Enviado"),
                     ("FIXING", u"Em resolução"),
                     ("TESTING", u"Em testes"),
                     ("FIXED", u"Resolvido"),
                     ("APPROVED", u"Aprovado"),
                     ("DISCARDED", u"Descartado"),
                     ("NON-BUG", u"Não é bug"),
                     ("POSTPONED", u"Adiado") )

POSSIBLE_SEVERITY = (('CRITICAL', u'Crítico'),
                     ('UNAVOIDABLE', u'Inevitável'),
                     ('AVOIDABLE', u'Evitável'),
                     ('COSMETIC', u'Cosmético'),
                     ('IMPROVEMENT', u'Melhorias') )


POSSIBLE_PRIORITY = ( (p, p) for p in range(1,6) )

class Bug(models.Model):
    ## todo FK user
#    reported_by = models.CharField(u'reportado por', max_length=32)
    reported_by = models.ForeignKey(User, verbose_name=u"reportado por", related_name='reported_bug_set')
    summary = models.CharField(u'sumário',max_length=128)
    status = models.CharField(choices = POSSIBLE_STATUS, max_length=16)
    priority = models.CharField(u'prioridade',choices = POSSIBLE_PRIORITY, max_length = 16)
    severity  = models.CharField(u'severidade',choices = POSSIBLE_SEVERITY,max_length = 16)
    error_message = models.TextField(u'descrição do problema')
    url = models.CharField(u'link',max_length = 128)
    browser = models.CharField(max_length = 32)
    steps_to_reproduce = models.TextField(u'como reproduzir o erro')
    comments = models.TextField(u'comentários')
#    assigned_to = models.CharField(u'responsável', max_length=32)
    assigned_to = models.ForeignKey(User, verbose_name=u"responsável", related_name='assigned_bug_set')
    workaround = models.TextField(u'procedimento provisório')
    actual_time_to_fix = models.IntegerField(u'tempo de resolução')
    log = models.TextField(u'log de resolução')
    modification_time = models.DateTimeField(u'modificado em')
    

